package com.ruoyi.analysis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.analysis.domain.OnlineHistoryZla;
import com.ruoyi.analysis.service.IOnlineHistoryZlaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 制粒一车间分析历史Controller
 * 
 * @author weihanqiang
 * @date 2025-06-19
 */
@RestController
@RequestMapping("/analysis/zla")
public class OnlineHistoryZlaController extends BaseController
{
    @Autowired
    private IOnlineHistoryZlaService onlineHistoryZlaService;

    /**
     * 查询制粒一车间分析历史列表
     */
    @PreAuthorize("@ss.hasPermi('analysis:zla:list')")
    @GetMapping("/list")
    public TableDataInfo list(OnlineHistoryZla onlineHistoryZla)
    {
        startPage();
        List<OnlineHistoryZla> list = onlineHistoryZlaService.selectOnlineHistoryZlaList(onlineHistoryZla);
        return getDataTable(list);
    }

    /**
     * 导出制粒一车间分析历史列表
     */
    @PreAuthorize("@ss.hasPermi('analysis:zla:export')")
    @Log(title = "制粒一车间分析历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OnlineHistoryZla onlineHistoryZla)
    {
        List<OnlineHistoryZla> list = onlineHistoryZlaService.selectOnlineHistoryZlaList(onlineHistoryZla);
        ExcelUtil<OnlineHistoryZla> util = new ExcelUtil<OnlineHistoryZla>(OnlineHistoryZla.class);
        util.exportExcel(response, list, "制粒一车间分析历史数据");
    }

    /**
     * 获取制粒一车间分析历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('analysis:zla:query')")
    @GetMapping(value = "/{onlineResultId}")
    public AjaxResult getInfo(@PathVariable("onlineResultId") Long onlineResultId)
    {
        return success(onlineHistoryZlaService.selectOnlineHistoryZlaByOnlineResultId(onlineResultId));
    }

    /**
     * 新增制粒一车间分析历史
     */
    @PreAuthorize("@ss.hasPermi('analysis:zla:add')")
    @Log(title = "制粒一车间分析历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OnlineHistoryZla onlineHistoryZla)
    {
        return toAjax(onlineHistoryZlaService.insertOnlineHistoryZla(onlineHistoryZla));
    }

    /**
     * 修改制粒一车间分析历史
     */
    @PreAuthorize("@ss.hasPermi('analysis:zla:edit')")
    @Log(title = "制粒一车间分析历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OnlineHistoryZla onlineHistoryZla)
    {
        return toAjax(onlineHistoryZlaService.updateOnlineHistoryZla(onlineHistoryZla));
    }

    /**
     * 删除制粒一车间分析历史
     */
    @PreAuthorize("@ss.hasPermi('analysis:zla:remove')")
    @Log(title = "制粒一车间分析历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{onlineResultIds}")
    public AjaxResult remove(@PathVariable Long[] onlineResultIds)
    {
        return toAjax(onlineHistoryZlaService.deleteOnlineHistoryZlaByOnlineResultIds(onlineResultIds));
    }
}
